//
//  ByModelLocationCity.m
//  chequanbao_ios
//
//  Created by pro on 17/5/25.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByModelLocationCity.h"

@implementation ByModelLocationCity

- (instancetype)initWithSuper:(ByCoreCityModel *)c_model {
    
    if (self = [super init]) {
        
        self.city = c_model.city;
        self.cityID = c_model.cityID;
        self.id = c_model.id;
        self.father = c_model.father;
        self.firstLetter = [self fisrtLetter:self.city];
    }
    return self;
}
- (NSString *)fisrtLetter:(NSString *)aString {
    
    // 转成了可变字符串
    NSMutableString *str = [NSMutableString stringWithString:aString];
    // 先转换为带声调的拼音
    CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformMandarinLatin, NO);
    // 再转换为不带声调的拼音
    CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformStripDiacritics, NO);
    // 转化为大写拼音
    NSString *pinYin = [str capitalizedString];
    // 获取并返回首字母
    return [pinYin substringToIndex:1];
}
@end
